uniform sampler2D texture;
uniform sampler2D texture1;

in vec4 out_color;
in vec3 world_pos;
in vec2 out_uv;
in float3x3 out_tangent_world_mtx;

void main()
{
	float3 directional_diffuse;

	float4 difftex=texture2D(texture, out_uv);
	float3 normaltex=texture2D(texture1, out_uv).xyz*2-float3(1,1,1);
	float3 world_normal=normalize(out_tangent_world_mtx*normaltex);
	float3 ambient_color=float3(0.3,0.3,0.3);
	directional_diffuse=saturate(dot(world_normal, normalize(directional_light.xyz)))*float3(1,1,1);
	
	gl_FragColor.a=object_color.a*out_color.a;
	gl_FragColor.xyz=difftex.xyz*out_color.xyz*(ambient_color+directional_diffuse+get_light_color(world_pos,world_normal).xyz)*object_color.xyz;
}